import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

const Home=()=>import("../views/home/Home")
const Cart=()=>import("../views/cart/Cart")
const Classify=()=>import("../views/classify/Classify")
const Profile=()=>import("../views/profile/Profile")

const routes=[
  {
    path :'',
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home,
    meta: {
      title: '首页'
    }
  },
  {
    path: '/cart',
    component: Cart,
    meta: {
      title: '购物车'
    }
  },
  {
    path: '/classify',
    component: Classify,
    meta: {
      title: '分类'
    }
  },
  {
    path: '/profile',
    component: Profile,
    meta: {
      title: '档案'
    }
  }
]
const router=new Router({
  routes,
  mode: 'history'
})
router.beforeEach((to, from, next) => {
  document.title=to.matched[0].meta.title
  next()
})
export default router
